home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 01 / 6 / DISK0162.ZIP / INPUT.INC < prev    next >
Text File  |  1984-06-25  |  2KB  |  96 lines

  1. ' INPUT.INC:    Some input routines that make life easier.
  2. '
  3. ' version:        6-25-84
  4. ' compiler:        Structured BASIC v1.12
  5. ' uses:            nothing
  6. ' module type:    include
  7. '
  8. ' To use the routines in this file, you must have the statement
  9. '
  10. '        include INPUT.INC
  11. '
  12. ' in your program.  Prior to using any of these procedures, use 
  13. ' the statement
  14. '
  15. '        do INITIALIZE.INPUT
  16. '
  17. ' You can change the variable IN.CHAR$ anytime to need to check for
  18. ' different legal characters, such as digits-only.  You shouldn't
  19. ' need to change the cursor blink value except if you compile.
  20.  
  21. procedure INITIALIZE.INPUT        'Initialize cursor and proof string
  22.     IN.CHAR$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "
  23.     IN.BLINK = 5 : IN.CURCNT = IN.BLINK
  24. endproc
  25.  
  26. procedure GET.YES.OR.NO            'Get a yes or no answer from user
  27.     'ANSWER contains either YES (1) or NO (0) on exit.
  28.     IN.GOTIT = 0 : YES = 1 : NO = 0
  29.     repeat
  30.         do IN.GET.KEY
  31.         if IN.KEY$ = "Y"
  32.             IN.GOTIT = 1
  33.             ANSWER = YES
  34.         elseif IN.KEY$ = "N"
  35.             IN.GOTIT = 1
  36.             ANSWER = NO
  37.         endif
  38.     until IN.GOTIT = 1
  39. endproc
  40.  
  41. procedure GET.STRING            'Get string from keyboard
  42.     IN.INPUT$ = ""
  43.     IN.START.COL = pos(0)
  44.     repeat
  45.         do IN.GET.KEY
  46.         if IN.KEY$ = chr$(13) break
  47.         if IN.KEY$ = chr$(8)
  48.             do IN.DEL.CHAR
  49.         elseif INSTR(IN.CHARS$,IN.KEY$) > 0
  50.             do IN.INS.CHAR
  51.         else
  52.             beep
  53.         endif
  54.     until 1 = 0
  55. endproc
  56.  
  57. procedure IN.GET.KEY             'Get uppercase key from keyboard
  58.     repeat
  59.         do IN.CURSOR
  60.         IN.KEY$ = INKEY$
  61.     until LEN(IN.KEY$) > 0
  62.     if asc(IN.KEY$) > 96 and asc(IN.KEY$) < 123
  63.         IN.KEY$ = chr$(asc(IN.KEY$) - 32)
  64.     endif
  65. endproc
  66.  
  67. procedure IN.INS.CHAR            'Add char to end of input string
  68.     print IN.KEY$;
  69.     IN.INPUT$ = IN.INPUT$ + IN.KEY$
  70. endproc
  71.  
  72. procedure IN.DEL.CHAR            'Handle backspace key in input
  73.     IN.CUR.COL = pos(0)
  74.     if IN.CUR.COL > IN.START.COL
  75.         IN.INPUT$ = LEFT$(IN.INPUT$,LEN(IN.INPUT$)-1)
  76.         print " ";
  77.         locate ,IN.CUR.COL-1
  78.     else
  79.         beep
  80.     endif
  81. endproc
  82.  
  83. procedure IN.CURSOR                'Simulate BASIC cursor
  84.     if IN.CURCNT = IN.BLINK
  85.         if IN.CURCHAR$ = chr$(&H5F)
  86.             IN.CURCHAR$ = " "
  87.         else
  88.             IN.CURCHAR$ = chr$(&H5F)
  89.         endif
  90.         IN.CURCNT = 0
  91.     endif
  92.     print IN.CURCHAR$;
  93.     IN.CURCNT = IN.CURCNT + 1
  94.     locate ,pos(0)-1
  95. endproc
  96.